package com.gome.base;

import com.gome.vue4j.core.AbstractVue4jComponent;
import com.gome.vue4j.core.FXMLPath;
import javafx.fxml.FXML;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 条件渲染,事件绑定
 */
@FXMLPath("/base/l5z1-view.fxml")
public class L5Z1ForComponent extends AbstractVue4jComponent {
    @FXML
    public Map<String,Actor> actors = new LinkedHashMap<String, Actor>(){
        {
            put("张飞",new Actor(1L,"张飞",28));
            put("关羽",new Actor(2L,"关羽",32));
            put("刘备",new Actor(3L,"刘备",36));
        }
    };

    @FXML
    void addActor(){
        long id = System.currentTimeMillis();
        String name = "群众" + id;
        actors.put(name,new Actor(id, name,22));
        update();
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Actor{
        Long id;
        String name;
        int age;
    }
}
